Function Reference

GUICtrlCreateIcon

Creates an Icon control for the GUI.

GUICtrlCreateIcon ( filename, iconName, left, top [, width [, height [, style [, exStyle]]]] )

 

Parameters

filename filename of the icon to be loaded.
iconName Icon name if the file contain multiple icon. Can be an ordinal name if negative number. Otherwise -1.
left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width [optional] The width of the control (default is 32).
height [optional] The height of the control (default is 32).
style [optional] Defines the style of the control. See GUI Control Styles Appendix.

default ( -1) : $SS_NOTIFY
forced styles : $WS_TABSTOP, $SS_ICON
exStyle [optional] Defines the extended style of the control. See Extended Style Table.

 

Return Value

Success: Returns the identifier (controlID) of the new control.
Failure: Returns 0.

 

Remarks

To set or change information in the control see GUICtrlSet....

To update the icon after the dialog box is displayed use GUICtrlSetImage

iconID can reference the icon group number. Use a resource hacker to know the value.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_ICON, newstyle,...).

Default resizing is $GUI_DOCKSIZE.

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

 

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg

 

Example


#include <GUIConstants.au3>

;example1 ---------------------------
GUICreate(" My GUI Icons")

$icon = GUICtrlCreateIcon ("shell32.dll",10, 20,20)
$icon2 = GUICtrlCreateIcon ("explorer.icl",10, 20,80)
$icon3 = GUICtrlCreateIcon ("explorer.icl",6, 80,80)
$n1=GUICtrlCreateIcon (@windowsdir & "\cursors\horse.ani",-1, 20,120,32,32)
$n2=GUICtrlCreateIcon ("shell32.dll",7 ,20,160,32,32)
GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend




; example2 ---------------------------
Opt("GUICoordMode",1)

GUICreate("My GUI icon Race", 350,74,-1,-1)
GUICtrlCreateLabel ("", 331,0,1,74,5)
$n1=GUICtrlCreateIcon (@windowsdir & "\cursors\dinosaur.ani", -1, 0,0,32,32)
$n2=GUICtrlCreateIcon ( @windowsdir & "\cursors\horse.ani", -1, 0,40,32,32)

GUISetState (@SW_SHOW)

Dim $a = 0, $b = 0
While ($a < 300) And ($b < 300)
  $a = $a + int(Random(0,1)+0.5)
  $b = $b + int(Random(0,1)+0.5)
  GUICtrlSetPos($n1, $a,0)
  GUICtrlSetPos($n2, $b,40)
  Sleep(20)
WEnd
sleep(1000)